home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_stscope_m.cog < prev    next >
Text File  |  1998-02-25  |  11KB  |  483 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # WEAP_STRIFLE.COG
  4. #
  5. # WEAPON 13 script - Stormtrooper Rifle
  6. #
  7. # The standard rifle used by the stormtroopers.  Not as accurate as the Bryar Pistol.
  8. # This weapon has only one type of fire.
  9. #
  10. # - Affected by MagSealed sectors/surfaces.
  11. #
  12. # [YB & CYW]
  13. #
  14. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  15.  
  16.  
  17. symbols
  18.  
  19. model       povModel=nullpov.3do                local
  20. model       weaponMesh=sscg.3do                 local
  21.  
  22. keyframe    mountAnim=sscVmnt.key               local
  23. keyframe    dismountAnim=sscVdis.key            local
  24. keyframe    povfireAnim=sscVpst1.key            local
  25. keyframe    holsterAnim=schlstr.key             local
  26.  
  27. sound       mountSound=df_rif_ready.wav         local
  28. sound       dismountSound=PutWeaponAway01.wav   local
  29. sound       fireSound=trprsht2.wav              local
  30. sound       outSound=trprout.wav                local
  31.  
  32. template    projectile=+sclaser                 local
  33.  
  34. thing       player                              local
  35. thing       lookthing                           local
  36.  
  37. flex        fireWait=0.5                        local
  38. flex        holsterWait                         local
  39. flex        powerBoost                          local
  40. flex        autoAimFOV=0.1                      local
  41. flex            magnification=4.0                            local
  42. flex            tempflex                                        local
  43.  
  44. int            iZoomPoint=1                                local
  45.  
  46. flex            fZoomTable=0.0                                local
  47. flex            fZoomTable1=4.0                            local
  48. flex            fZoomTable2=11.0                            local
  49. flex            fZoomTable3=23.0                            local
  50. flex            fZoomTable4=0.0                            local
  51.  
  52. int         dummy                               local
  53. int         trackID=-1                          local
  54. int         fireChannel=-1                      local
  55. int         holsterTrack                        local
  56. int         mode                                local
  57. int            manualMode=0                                local
  58.  
  59. int            greenEffectHandle=-1                        local
  60.  
  61. int            modeSwitchDown=0                            local
  62.  
  63.  
  64. message        newplayer
  65. message        shutdown
  66. message        playeraction
  67. message     activated
  68. message     deactivated
  69. message     selected
  70. message     deselected
  71. message     autoselect
  72. message     fire
  73. message     timer
  74. message        pulse
  75. message        killed
  76.  
  77. end
  78.  
  79. # ========================================================================================
  80.  
  81. code
  82.  
  83. newplayer:
  84.     if (greenEffectHandle != -1)
  85.     {
  86.         freeColorEffect(greenEffectHandle);
  87.  
  88.         greenEffectHandle = -1;
  89.     }
  90.  
  91.     SetCameraZoom(0, 1.0, 500.0);
  92.     ClearActorFlags(GetLocalPlayerThing(), 0x20000000);
  93.     return;
  94.  
  95. fire:
  96.    player = GetSourceRef();
  97.    mode = GetSenderRef();
  98.  
  99.         // Don't do anything in mode 1.
  100.     if (mode == 1)
  101.         return;
  102.  
  103.    // Check that the player is still alive.
  104.    if(GetThingHealth(player) <= 0)
  105.    {
  106.       Return;
  107.    }
  108.  
  109.     // The player may want to use the scope even if they
  110.     // don't have ammo for it, so don't autoswitch away.
  111.  
  112.    // Check Ammo - If we are out, autoselect best weapon.
  113.    // It should always use two energy cells, but -- as in DF --
  114.    // allow the last fire if there is only one left...
  115. //   if(GetInv(player, 11) < 1.0)
  116. //   {
  117. //      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
  118. //      if((GetAutoSwitch() & 1))
  119. //         SelectWeapon(player, GetWeaponBin(AutoSelectWeapon(player, 1)));
  120. //      Return;
  121. //   }
  122.  
  123.  
  124.         // Only fire if we have the ammo.
  125.     if(GetInv(player, 11) > 1.0)
  126.     {
  127. //        SetPOVShake('0.0 -.003 0.0', '1.5 0.0 0.0', .05, 80.0);
  128.  
  129.         SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  130.  
  131.             // If this is the scout, double the damage and make no sound.
  132.       if (jkGetMultiParam (0) == 3)
  133.             dummy = FireProjectile(player, projectile, -1, -1, '0.0 0.0 0.035', '0 0 0', 2.0, 0x2, autoAimFOV, autoAimFOV);
  134.         else
  135.             dummy = FireProjectile(player, projectile, fireSound, -1, '0.0 0.0 0.035', '0 0 0', 1.0, 0x0, autoAimFOV, autoAimFOV);
  136.  
  137.         ChangeInv( player, 11, -4.0 );
  138. //        jkPlayPOVKey( player, povfireAnim, 1, 0x38 );
  139.  
  140.         powerBoost = GetInv(player, 63);
  141.         ChangeFireRate(player, fireWait/powerBoost);
  142.     }
  143.  
  144.    Return;
  145.  
  146. # ........................................................................................
  147.  
  148. activated:
  149.    player = GetSourceRef();
  150.    mode = GetSenderRef();
  151.  
  152.     if (mode == 1)
  153.     {
  154.         manualMode = 1 - manualMode;
  155.  
  156.             // Capture jump and crouch.
  157.         if (manualMode == 1)
  158.         {
  159.             magnification = fZoomTable[iZoomPoint];
  160.             SetCameraZoom(0, magnification, 150.0);
  161.  
  162.             SetActionCog(GetSelfCog(), 0x4083);
  163.             jkPrintUNIString(player, 386);        //    Manual Zoom Mode
  164.         }
  165.         else
  166.         {
  167.             SetActionCog(GetSelfCog(), 0x4080);
  168.             jkPrintUNIString(player, 385);        //    Automatic Zoom Mode
  169.         }
  170.  
  171.       modeSwitchDown = 1;
  172.     }
  173.     else
  174.     {
  175.         jkSetWaggle(player, '0.0 0.0 0.0', 0);
  176.         powerBoost = GetInv(player, 63);
  177.         ActivateWeapon(player, fireWait/powerBoost, mode);
  178.     }
  179.    Return;
  180.  
  181. # ........................................................................................
  182.  
  183. deactivated:
  184.    mode = GetSenderRef();
  185.  
  186.     if (mode == 1)
  187.     {
  188.       modeSwitchDown = 0;
  189.  
  190.         return;
  191.     }
  192.  
  193.    player = GetSourceRef();
  194.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  195.    DeactivateWeapon(player, mode);
  196.    Return;
  197.  
  198. # ........................................................................................
  199.  
  200. selected:
  201.    player = GetSourceRef();
  202.  
  203.    PlayMode(player, 41);
  204.    PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
  205.     jkSetPOVModel(player, povModel);
  206.    SetArmedMode(player, 1);
  207.    jkSetWeaponMesh(player, weaponMesh);
  208.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  209.    trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
  210.    SetMountWait(player, GetKeyLen(mountAnim));
  211.    jkClearFlags(player, 0x5);
  212.    SetCurWeapon(player, GetWeaponBin(13));
  213.  
  214.     if (greenEffectHandle != -1)
  215.     {
  216.         freeColorEffect(greenEffectHandle);
  217.  
  218.         greenEffectHandle = -1;
  219.     }
  220.     greenEffectHandle = newColorEffect(1.0, 0, 0,  0, 0, 0,  0, 0, 0,  1.0);
  221.     EnableIRMode(0.3, 1);
  222.  
  223.         // Go to primary view.
  224.     SetCurrentCamera(0);
  225.  
  226.         // Turn on Scope hud.
  227.     SetActorFlags(player, 0x20000000);
  228.  
  229.         // Turn on zoom
  230.     if (!manualMode)
  231.     {
  232.         jkPrintUNIString(player, 385);        //    Automatic Zoom Mode
  233.  
  234.         SetActionCog(GetSelfCog(), 0x4080);
  235.         iZoomPoint = 1;
  236.         magnification=fZoomTable[iZoomPoint];
  237.         SetPulse(0.25);
  238.     }
  239.     else
  240.     {
  241.         jkPrintUNIString(player, 386);        // Manual Zoom Mode
  242.  
  243.         SetActionCog(GetSelfCog(), 0x4083);
  244.     }
  245.  
  246.     if (GetCurWeapon(player) == 13)
  247.         SetCameraZoom(0, magnification, 500.0);
  248.  
  249.    Return;
  250.  
  251. # ........................................................................................
  252.  
  253. deselected:
  254.    player = GetSourceRef();
  255.  
  256.     if (greenEffectHandle != -1)
  257.     {
  258.         freeColorEffect(greenEffectHandle);
  259.  
  260.         greenEffectHandle = -1;
  261.     }
  262.  
  263.         // Turn off Scope hud.
  264.     ClearActorFlags(player, 0x20000000);
  265.  
  266.    PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
  267.    jkPlayPOVKey(player, dismountAnim, 0, 18);
  268.    holsterWait = GetKeyLen(holsterAnim);
  269.    SetMountWait(player, holsterWait);
  270.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  271.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  272.    if (trackID != -1)
  273.    {
  274.       jkStopPOVKey(player, trackID, 0);
  275.       trackID = -1;
  276.    }
  277.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  278.  
  279.    // Don't disable IR mode if IR Goggles are on...
  280.    if    (
  281.         !IsInvActivated(player, 41) &&
  282.         !IsInvActivated(player, 23)
  283.         )
  284.       DisableIRMode();
  285.  
  286.         // Turn off zoom
  287.     SetPulse(0.0);
  288.     SetCameraZoom(0, 1.0, 500.0);
  289.  
  290.     SetActionCog(-1, 0);
  291.  
  292.    Return;
  293.  
  294. # ........................................................................................
  295.  
  296. autoselect:
  297.    player = GetSourceRef();
  298.  
  299.         // If the player has both the rifle and the scope...
  300.    if (
  301.         (GetInv(player, GetWeaponBin(3)) != 0.0) &&
  302.         (GetInv(player, GetWeaponBin(13)) != 0.0)
  303.         )
  304.    {
  305.         // If the player has ammo
  306.         if(GetInv(player, 11) != 0.0)
  307.         {
  308.             ReturnEx(550.0);
  309.         }
  310.         else
  311.         {
  312.                 // You can still arm with no ammo, it's just a very low priority.
  313.             ReturnEx(1.0);
  314.         }
  315.    }
  316.    else
  317.    {
  318.       ReturnEx(-1.0);
  319.    }
  320.  
  321.         // Scope doesn't work in the temple.
  322.     if (GetInv(player, 93) > 0.0)
  323.       ReturnEx(-1.0);
  324.  
  325.    Return;
  326.  
  327. # ........................................................................................
  328.  
  329. timer:
  330.    StopKey(player, holsterTrack, 0.0);
  331.    Return;
  332.  
  333. # ........................................................................................
  334.  
  335. playeraction:
  336.     if (GetCurWeapon(GetLocalPlayerThing()) != 13)
  337.     {
  338.         SetActionCog(-1, 0);
  339.         return;
  340.     }
  341.  
  342.     if (manualMode == 1)
  343.     {
  344.         if (GetParam(0) == 0.0)            // Jump
  345.         {
  346.             if (GetParam(2) == 1.0)
  347.             {
  348.                 iZoomPoint = iZoomPoint + 1;
  349.  
  350.                 if (fZoomTable[iZoomPoint] != 0.0)
  351.                 {
  352.                magnification = fZoomTable[iZoomPoint];
  353.         
  354.                     if (magnification < 4.0)
  355.                         magnification = 4.0;
  356.                     else if (magnification > 23.0)
  357.                         magnification = 23.0;
  358.     
  359.                     SetCameraZoom(0, magnification, 150.0);
  360.                 }
  361.                 else
  362.                 {
  363.                     iZoomPoint = iZoomPoint - 1;
  364.                 }
  365.             }
  366.         }
  367.     
  368.         if (GetParam(0) == 1.0)            // Crouch
  369.         {
  370.             if (GetParam(2) == 1.0)
  371.             {
  372.                 iZoomPoint = iZoomPoint - 1;
  373.  
  374.                 if (fZoomTable[iZoomPoint] != 0.0)
  375.                 {
  376.                magnification = fZoomTable[iZoomPoint];
  377.         
  378.                     if (magnification < 4.0)
  379.                         magnification = 4.0;
  380.                     else if (magnification > 23.0)
  381.                         magnification = 23.0;
  382.     
  383.                     SetCameraZoom(0, magnification, 150.0);
  384.                 }
  385.                 else
  386.                 {
  387.                     iZoomPoint = iZoomPoint + 1;
  388.                 }
  389.             }
  390.         }
  391.     }
  392.  
  393. //    if (GetParam(0) == 2.0)            // Activate
  394. //    {
  395. //        manualMode = 1 - manualMode;
  396. //
  397. //        if (manualMode)
  398. //            SetPulse(0.0);
  399. //        else
  400. //            SetPulse(0.25);
  401. //    }
  402.  
  403.     if (GetParam(0) == 7.0)                // Select Weapon
  404.     {
  405.         if (!modeSwitchDown)                // Don't allow weapon switches if
  406.         {                                        // Secondary fire is active.
  407.             ReturnEx(1.0);
  408.             return;
  409.         }
  410.     }
  411.  
  412.     if (GetParam(0) == 14.0)            // Other action
  413.     {
  414.         if (GetParam(2) != 0.0)            // Everything is OK except cycle camera.
  415.         {
  416.             ReturnEx(1.0);
  417.             return;
  418.         }
  419.     }
  420.  
  421.     ReturnEx(0.0);
  422.     return;
  423.  
  424. # ........................................................................................
  425.  
  426. pulse:
  427.     if (GetCurWeapon(GetLocalPlayerThing()) == 13)
  428.     if (manualMode == 0)
  429.     {
  430.         lookthing =    FirstThingInView(player, 10, 100, 0x404);
  431.  
  432.         if (lookthing && (lookthing != -1))
  433.         {
  434.             tempflex = VectorDist(GetThingPos(lookthing), GetThingPos(player));
  435.  
  436.             magnification = (tempflex * 2.0) + 1.0;
  437.         }
  438.         else
  439.         {
  440.             magnification = 4.0;
  441.         }
  442.  
  443.         if (magnification < 4.0)
  444.             magnification = 4.0;
  445.  
  446.         SetCameraZoom(0, magnification, 150.0);
  447.     }
  448.     return;
  449.  
  450. # ........................................................................................
  451.  
  452. killed:
  453.         // Reset the zoom level.
  454.    if (player == GetSenderRef())
  455.    {
  456.         if (greenEffectHandle != -1)
  457.         {
  458.             freeColorEffect(greenEffectHandle);
  459.  
  460.          greenEffectHandle = -1;
  461.         }
  462.  
  463.         SetCameraZoom(0, 1.0, 500.0);
  464.         ClearActorFlags(player, 0x20000000);
  465.  
  466.             //    Release the player controls.
  467. //        if (manualMode)
  468.         {
  469.             manualMode = 0;
  470.             SetActionCog(-1, 0);
  471.         }
  472.     }
  473.     return;
  474.  
  475. # ........................................................................................
  476.  
  477. shutdown:
  478.     SetCameraZoom(0, 1.0, 500.0);
  479.     ClearActorFlags(player, 0x20000000);
  480.     return;
  481.  
  482. end
  483.